﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.BaseData;
using NP.BPMReportPlatform.BaseData.Dto;
using NP.BPMReportPlatform.Entities.BPM_Business;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.StandardApprovalFlow
{
    /// <summary>
    /// 基础数据接口
    /// </summary>
    //[Authorize]
    [Route("api/BaseData")]
    public class BaseDataController : BPMReportPlatformController
    {
        private readonly IBaseDataAppService _baseDataAppSerice;

        public BaseDataController(IBaseDataAppService baseDataAppSerice)
        {
            _baseDataAppSerice = baseDataAppSerice;
        }


        /// <summary>
        /// 获取字典表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Route("GetKeyValues")]
        [HttpGet]
        public async Task<PagedResultDto<GetKeyValuesOutput>> GetKeyValues(GetKeyValuesInput input)
        {
            return await _baseDataAppSerice.GetKeyValues(input);
        }

        /// <summary>
        /// 获取字典表（单条数据）
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [Route("GetKeyValues/{id}")]
        [HttpGet]
        public async Task<GetKeyValuesOutput> GetKeyValues([FromRoute] Guid id)
        {
            return await _baseDataAppSerice.GetKeyValues(id);
        }

        /// <summary>
        /// 更新培训区域排序
        /// </summary>
        /// <param name="list">集合</param>
        /// <returns></returns>
        [HttpPost]
        [Route("UpdateSort")]
        public async Task<bool> UpdateSortAsync([FromBody] List<KeyValues> list)
        {
            return await _baseDataAppSerice.UpdateSort(list);
        }

        /// <summary>
        /// 获取数据字典
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [Route("GetDictionary/{code}")]
        [HttpGet]
        public async Task<List<DictionaryOutput>> GetDictionary([FromRoute] string code)
        {
            return await _baseDataAppSerice.GetDictionary(code);
        }
        /// <summary>
        /// 获取数据字典
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Route("GetCityData")]
        [HttpPost]
        public async Task<List<CityOutput>> GetCityData([FromBody] GetCityInput input)
        {
            return await _baseDataAppSerice.GetCityData(input);
        }
    }
}
